<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            border: 1px solid gray;
            width: 500px;
            margin: 100px auto;
            text-align: center;
        }

        tr {
            height: 40px;
        }

        td,
        th {
            border: 1px solid gray;
        }
    </style>
</head>

<body>
    <table>
        <thead>
            <tr>
                <th>姓名</th>
                <th>科目</th>
                <th>成绩</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>

        </tbody>
    </table>


</body>
<script>
    var sr = [{
        name: '张大',
        subject: 'javascript',
        score: 100
    },
    {
        name: '张二',
        subject: 'javascript',
        score: 90
    },
    {
        name: '张三',
        subject: 'javascript',
        score: 80
    }]
    var tt = document.querySelector('tbody');
    for (var i = 0; i < sr.length; i++) {
        var tr = document.createElement('tr')
        tt.appendChild(tr)
        for (var k in sr[i]) {
            var td = document.createElement('td')
            td.innerHTML = sr[i][k];
            tr.appendChild(td)
        }
        var sc = document.createElement('td')
        sc.innerHTML = "<a href='jiavescript:;'> 删除 </a>"
        tr.appendChild(sc)
    }
    var a = document.querySelectorAll('a')
    for (var i = 0; i < a.length; i++) {
        a[i].onclick = function () {
            tt.removeChild(this.parentNode.parentNode)
        }
    }
</script>

</html>